When activating the feature `foo/bar` you're actually activating both the
feature `foo` and the `bar` feature of the relevant package. Cargo previously
forgot to activate the `foo` feature, and this commit fixes that up.
Closes #1871
match parts.next() {
Some(feat) => {
let package = feat_or_package;
+ used.insert(package.to_string());
deps.entry(package.to_string())
.or_insert(Vec::new())
.push(feat.to_string());
{compiling} test v0.1.0 ([..])
", compiling = COMPILING)));
});
+
+test!(activating_feature_activates_dep {
+ let p = project("foo")
+ .file("Cargo.toml", r#"
+ [package]
+ name = "test"
+ version = "0.1.0"
+ authors = []
+
+ [dependencies]
+ foo = { path = "foo", optional = true }
+
+ [features]
+ a = ["foo/a"]
+ "#)
+ .file("src/lib.rs", "
+ extern crate foo;
+ pub fn bar() {
+ foo::bar();
+ }
+ ")
+ .file("foo/Cargo.toml", r#"
+ [package]
+ name = "foo"
+ version = "0.1.0"
+ authors = []
+
+ [features]
+ a = []
+ "#)
+ .file("foo/src/lib.rs", r#"
+ #[cfg(feature = "a")]
+ pub fn bar() {}
+ "#);
+
+ assert_that(p.cargo_process("build").arg("--features").arg("a").arg("-v"),
+ execs().with_status(0));
+});